package problem206;

//206.反转链表
//https://leetcode.cn/problems/reverse-linked-list/

class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode newHead = new ListNode();
        ListNode cur = head;
        while(cur != null) {
            ListNode next = cur.next;
            cur.next = newHead.next;
            newHead.next = cur;
            cur = next;
        }
        return newHead.next;
    }
}